import {commonGetOptions} from "@/utils/format-table";
import {DictOptions} from "@/utils/common-types";

/**
 * 获取options
 * 使用方法:
 *      const tempOptions = useGetOptions(DictType.Status, DictType.Gender);
 *     const statusOptions = computed(() => tempOptions.value[0])
 *     const genderOptions = computed(() => tempOptions.value[1])
 * @param codes
 */
export function useGetOptions(...codes: string[]) {
    const options: Ref<DictOptions[][]> = ref([])
    Promise.all(commonGetOptions(...codes)).then(results => {
        results.forEach((item, index) => {
            options.value[index] = item
        })
    })
    return options
}
